function SurveyChart(chartDiv,title,yAxisName,seriesArray,type,startTime,endTime,dataMap){
	this.chartDiv = chartDiv;
	this.title = title;
	this.yAxisName = yAxisName;
	this.seriesArray = seriesArray;
	this.type=type;
	this.startTime=startTime;
	this.endTime = endTime;
	this.dataMap = dataMap;
	this.chartString = generateDataString();
	function generateDataString(){
		var DAY = 24*60*60*1000;
		var dataStr ="<chart caption='"+ title+"' baseFontSize='12' palette='2' YAxisName='"+ yAxisName+"' numdivlines='8' showValues='0' anchorRadius='3' numVDivLines='11' showAlternateVGridColor='1' alternateVGridAlpha='3' formatNumber='0' formatNumberScale='0' decimals='2' animation='1' numVisiblePlot='12' legendBorderAlpha='0'>";
		if(type=="day"){
			var FORMAT ="yyyy-MM-dd";
			var startDate = Date.parse(startTime,FORMAT);
			var endDate =  Date.parse(endTime,FORMAT);
			var start = startDate.valueOf();
			var end = endDate.valueOf();
			dataStr+="<categories >";
			for(var time = start;time<=end;time+=DAY){
				var day = new Date();
				day.setTime(time);
				var key = day.format("MM-dd");
				dataStr+="<category label='"+key+"' />";
			}
			dataStr+="</categories>";
			var max = seriesArray.length-1;
			for(var i in seriesArray){
				dataStr+="<dataset seriesName='"+seriesArray[i]+"'";
				if(i==max){
					dataStr+=" renderAs='Line'";
				}else{
					dataStr+=" renderAs='Area'";
				}
				dataStr+=">";
				for(var time = start;time<=end;time+=DAY){
					var day = new Date();
					day.setTime(time);
					var key = "key_"+day.format("MMdd")+"_"+i;
					var value = dataMap[key];
					if (value === undefined){
						value =0;
					}
		    		dataStr+='<set value="'+value+'"/>';
				}
				dataStr+="</dataset>";
			}
			dataStr+="</chart>";
		}else{
			dataStr+="<categories >";
			for(var time = start;time<=end;time++){
				dataStr+="<category label='"+time+"' />";
			}
			dataStr+="</categories>";
			dataStr+="<dataset>";
			for(var time = start;time<=end;time+=DAY){
				var value = dataMap[time];
				if (value === undefined){
					value =0;
				}
	    		dataStr+='<set value="'+value+'"/>';
			}
			dataStr+="</dataset>";
			dataStr+="</chart>";
		}
        return dataStr;
    }
};
SurveyChart.prototype.draw = function(){
	var chart = new FusionCharts("../static/FusionCharts/MSCombi2D.swf", "SurveyChartId", "726", "325", "0", "0");
    chart.setXMLData(this.chartString);
    chart.render(this.chartDiv);
};

